package com.ruoyi.web.controller.qsng;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qsng.domain.KCourseRefund;
import com.ruoyi.qsng.service.IKCourseRefundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程退费Controller
 * 
 * @author kanglou
 * @date 2023-06-07
 */
@RestController
@RequestMapping("/qsng/refund")
@Api(tags = "pc--课程退费Controller")
public class KCourseRefundController extends BaseController
{
    @Autowired
    private IKCourseRefundService kCourseRefundService;

    /**
     * 查询课程退费列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:refund:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询课程退费列表")
    public TableDataInfo list(KCourseRefund kCourseRefund)
    {
        startPage();
        List<KCourseRefund> list = kCourseRefundService.selectKCourseRefundList(kCourseRefund);
        return getDataTable(list);
    }

    /**
     * 导出课程退费列表
     */
    @PreAuthorize("@ss.hasPermi('qsng:refund:export')")
    @Log(title = "课程退费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出课程退费列表")
    public void export(HttpServletResponse response, KCourseRefund kCourseRefund)
    {
        List<KCourseRefund> list = kCourseRefundService.selectKCourseRefundList(kCourseRefund);
        ExcelUtil<KCourseRefund> util = new ExcelUtil<KCourseRefund>(KCourseRefund.class);
        util.exportExcel(response, list, "课程退费数据");
    }

    /**
     * 获取课程退费详细信息
     */
    @PreAuthorize("@ss.hasPermi('qsng:refund:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取课程退费详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(kCourseRefundService.selectKCourseRefundById(id));
    }

    /**
     * 新增课程退费
     */
    @PreAuthorize("@ss.hasPermi('qsng:refund:add')")
    @Log(title = "课程退费", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增课程退费")
    public AjaxResult add(@RequestBody KCourseRefund kCourseRefund)
    {
        return toAjax(kCourseRefundService.insertKCourseRefund(kCourseRefund));
    }

    /**
     * 修改课程退费
     */
    @PreAuthorize("@ss.hasPermi('qsng:refund:edit')")
    @Log(title = "课程退费", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改课程退费")
    public AjaxResult edit(@RequestBody KCourseRefund kCourseRefund)
    {
        return toAjax(kCourseRefundService.updateKCourseRefund(kCourseRefund));
    }

    /**
     * 删除课程退费
     */
    @PreAuthorize("@ss.hasPermi('qsng:refund:remove')")
    @Log(title = "课程退费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除课程退费")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(kCourseRefundService.deleteKCourseRefundByIds(ids));
    }
}
